package com.letian.record.service.impl;

import java.sql.Time;
import java.time.LocalTime;
import java.util.List;
import com.letian.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.letian.record.mapper.RecordDrinkMapper;
import com.letian.record.domain.RecordDrink;
import com.letian.record.service.IRecordDrinkService;

/**
 * 饮用记录Service业务层处理
 * 
 * @author bmz
 * @date 2023-07-13
 */
@Service
public class RecordDrinkServiceImpl implements IRecordDrinkService 
{
    @Autowired
    private RecordDrinkMapper recordDrinkMapper;

    /**
     * 查询饮用记录
     * 
     * @param drinkId 饮用记录主键
     * @return 饮用记录
     */
    @Override
    public RecordDrink selectRecordDrinkByDrinkId(Long drinkId)
    {
        return recordDrinkMapper.selectRecordDrinkByDrinkId(drinkId);
    }

    /**
     * 查询饮用记录列表
     * 
     * @param recordDrink 饮用记录
     * @return 饮用记录
     */
    @Override
    public List<RecordDrink> selectRecordDrinkList(RecordDrink recordDrink)
    {
        return recordDrinkMapper.selectRecordDrinkList(recordDrink);
    }

    /**
     * 查询饮用记录列表
     *
     * @param recordDrink 饮用记录
     * @return 饮用记录
     */
    @Override
    public List<RecordDrink> selectRecordDrinkListToday(RecordDrink recordDrink)
    {
        return recordDrinkMapper.selectRecordDrinkListToday(recordDrink);
    }

    /**
     * 新增饮用记录
     * 
     * @param recordDrink 饮用记录
     * @return 结果
     */
    @Override
    public int insertRecordDrink(RecordDrink recordDrink)
    {
        recordDrink.setDrinkDate(DateUtils.getNowDate());
        recordDrink.setDrinkTime(Time.valueOf(LocalTime.now()));
        recordDrink.setCreateTime(DateUtils.getNowDate());
        return recordDrinkMapper.insertRecordDrink(recordDrink);
    }

    /**
     * 修改饮用记录
     * 
     * @param recordDrink 饮用记录
     * @return 结果
     */
    @Override
    public int updateRecordDrink(RecordDrink recordDrink)
    {
        recordDrink.setUpdateTime(DateUtils.getNowDate());
        return recordDrinkMapper.updateRecordDrink(recordDrink);
    }

    /**
     * 批量删除饮用记录
     * 
     * @param drinkIds 需要删除的饮用记录主键
     * @return 结果
     */
    @Override
    public int deleteRecordDrinkByDrinkIds(Long[] drinkIds)
    {
        return recordDrinkMapper.deleteRecordDrinkByDrinkIds(drinkIds);
    }

    /**
     * 删除饮用记录信息
     * 
     * @param drinkId 饮用记录主键
     * @return 结果
     */
    @Override
    public int deleteRecordDrinkByDrinkId(Long drinkId)
    {
        return recordDrinkMapper.deleteRecordDrinkByDrinkId(drinkId);
    }
}
